# {{ ansible_managed }}

{%- set all_calculated_max_connections = [] %}
{%- for galera_node in galera_cluster_members %}
    {%- set vcpus = hostvars[galera_node]['ansible_processor_vcpus'] %}
    {%- set _ = all_calculated_max_connections.append([[vcpus|default(2), 2] | max, galera_wsrep_slave_threads_max] | min * 100) %}
{%- endfor %}
{%- set calculated_min_connections = all_calculated_max_connections | min %}
{%- set calculated_max_connections = galera_max_connections | default(calculated_min_connections) %}

# How long to wait for successful mysql startup
# Startup can take a while if it requires a galera state transfer.
MYSQLD_STARTUP_TIMEOUT={{ galera_startup_timeout }}

ulimit -n  {{ calculated_max_connections }}
ulimit -Hn  {{ calculated_max_connections }}
